package com.oristartech.ori.common.facade;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.oristartech.ori.common.dto.Identity;
import com.oristartech.ori.common.facade.OrstFacade;
import com.oristartech.ori.common.service.OrstService;

/**
 ** 通用基础服务实现类
 * 
 * @author chenfenghai
 * @date 2019/02/28
 */
public class OrstFacadeImpl<M extends OrstService<T>, T> implements OrstFacade<T> {

    @Autowired
    protected M orstService;

    /**
     ** 插入一条记录
     * 
     * @param identity
     * @param entity
     **            实体对象
     * @return
     */
    @Override
    public int insert(Identity identity, T entity) {
        return orstService.insert(entity);
    }

    /**
     ** 插入一条记录，存在有效值的字段
     * 
     * @param identity
     * @param entity
     * @return
     */
    @Override
    public int insertSelective(Identity identity, T entity) {
        return orstService.insertSelective(entity);
    }

    /**
     ** 根据 ID删除记录
     * 
     * @param identity
     * @param id
     **            主键ID
     * @return
     */
    @Override
    public int deleteById(Identity identity, Serializable id) {
        return orstService.deleteById(id);
    }

    /**
     ** 根据 UID删除
     * 
     * @param identity
     * @param uid
     * @return
     */
    @Override
    public int deleteByUid(Identity identity, String uid) {
        return orstService.deleteByUid(uid);
    }

    /**
     ** 根据 ID修改
     * 
     * @param identity
     * @param entity
     * @return
     */
    @Override
    public int updateById(Identity identity, T entity) {
        return orstService.updateById(entity);
    }

    /**
     ** 根据ID修改实体对象有效值的字段
     * 
     * @param identity
     * @param entity
     * @return
     */
    @Override
    public int updateSelectiveById(Identity identity, T entity) {
        return orstService.updateSelectiveById(entity);
    }

    /**
     ** 根据UID修改
     * 
     * @param identity
     * @param entity
     * @return
     */
    @Override
    public int updateByUid(Identity identity, T entity) {
        return orstService.updateByUid(entity);
    }

    /**
     ** 根据UID修改实体对象有效值的字段
     * 
     * @param identity
     * @param entity
     * @return
     */
    @Override
    public int updateSelectiveByUid(Identity identity, T entity) {
        return orstService.updateSelectiveByUid(entity);
    }

    /**
     ** 根据 ID查询记录
     * 
     * @param identity
     * @param id
     * @return
     */
    @Override
    public T selectById(Identity identity, Serializable id) {
        return orstService.selectById(id);
    }

    /**
     ** 根据 UID查询记录
     * 
     * @param identity
     * @param uid
     * @return
     */
    @Override
    public T selectByUid(Identity identity, String uid) {
        return orstService.selectByUid(uid);
    }

    /**
     ** 根据对象有效值查询列表
     * 
     * @param identity
     * @param entity
     * @return
     */
    @Override
    public List<T> selectListSelective(Identity identity, T entity) {
        return orstService.selectListSelective(entity);
    }

    /**
     ** 根据对象有效值查询一条记录
     * 
     * @param identity
     * @param entity
     * @return
     */
    @Override
    public T selectOneSelective(Identity identity, T entity) {
        return orstService.selectOneSelective(entity);
    }
}
